<!DOCTYPE html>
<html>
<head>
    <title>Leaflet boundary canvas plugin example (popular baselayers)</title>

    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />

    <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
    <script src="http://leaflet-extras.github.io/leaflet-providers/leaflet-providers.js"></script>

    <script src="../src/BoundaryCanvas.js"></script>
    
    <style>
        html, body, #map {
            height: 100%;
            margin: 0px;
        }
    </style>
</head>

<body>
    <div id="map"></div>

    <script type="text/javascript">

    var geom = {"type":"Polygon","coordinates":[[[37.73337,56.94268],[37.74618,56.94007],[37.74538,56.93311],[37.78113,56.90472],[37.82385,56.91221],[37.84832,56.90239],[37.85892,56.90602],[37.87722,56.89823],[37.88719,56.87826],[37.90917,56.87838],[37.91059,56.88808],[37.94528,56.88625],[37.9645,56.86919],[37.98349,56.86615],[37.97424,56.86323],[37.98348,56.85247],[37.96896,56.85064],[37.99248,56.81334],[37.99179,56.77571],[37.99818,56.76927],[38.05082,56.76812],[38.05036,56.75186],[38.06298,56.7511],[38.06367,56.74006],[38.10641,56.7632],[38.15218,56.76174],[38.15767,56.76856],[38.18251,56.75345],[38.22395,56.74721],[38.2551,56.76724],[38.24578,56.79488],[38.25671,56.79158],[38.24955,56.78708],[38.25579,56.7826],[38.30268,56.76257],[38.3028,56.73994],[38.32185,56.72022],[38.32028,56.70512],[38.30499,56.69432],[38.32247,56.65849],[38.31863,56.64447],[38.34249,56.6314],[38.34384,56.61882],[38.3325,56.6048],[38.35533,56.59675],[38.36222,56.58113],[38.35867,56.5734],[38.28436,56.54083],[38.2851,56.52843],[38.27543,56.52659],[38.28677,56.51475],[38.33906,56.51644],[38.33358,56.50637],[38.29883,56.49592],[38.32169,56.48175],[38.34507,56.47873],[38.3513,56.46401],[38.34094,56.45896],[38.35167,56.45269],[38.36752,56.46277],[38.39473,56.4598],[38.40804,56.43837],[38.39876,56.42652],[38.41019,56.41736],[38.40001,56.4027],[38.44776,56.38775],[38.44422,56.3723],[38.40895,56.36761],[38.4232,56.36007],[38.41326,56.32038],[38.44076,56.31231],[38.43949,56.29471],[38.39563,56.26863],[38.41664,56.25572],[38.41117,56.25158],[38.41539,56.2356],[38.44476,56.22556],[38.45739,56.20386],[38.52673,56.21204],[38.49639,56.18082],[38.51993,56.15311],[38.51505,56.14941],[38.52265,56.14191],[38.51032,56.13318],[38.51253,56.12607],[38.53293,56.11474],[38.52858,56.10272],[38.53439,56.09476],[38.54882,56.09179],[38.54093,56.08262],[38.55438,56.07224],[38.55195,56.06284],[38.59133,56.05299],[38.59662,56.02784],[38.58982,56.02497],[38.61245,56.01519],[38.5709,55.99569],[38.6124,55.97647],[38.6932,55.98971],[38.72713,55.98229],[38.77178,55.95167],[38.80692,55.94188],[38.83815,55.91338],[38.88312,55.94472],[38.90106,55.94574],[38.9163,55.93402],[38.94154,55.93123],[38.9484,55.94271],[38.96432,55.936],[39.00258,55.94362],[39.01015,55.95228],[39.02622,55.94749],[39.04183,55.95384],[39.05504,55.94688],[39.03371,55.93638],[39.01058,55.94348],[39.00525,55.93519],[39.01112,55.92605],[39.03838,55.92077],[39.06248,55.93936],[39.06038,55.92715],[39.03131,55.91257],[39.07744,55.88028],[39.07056,55.86172],[39.10881,55.85931],[39.10821,55.84862],[39.13885,55.84872],[39.1506,55.85683],[39.17757,55.84003],[39.21133,55.85035],[39.27908,55.83971],[39.28478,55.84906],[39.32655,55.86206],[39.32917,55.84644],[39.29573,55.83004],[39.31021,55.80509],[39.32171,55.8017],[39.32598,55.77296],[39.37603,55.76673],[39.40214,55.77269],[39.40786,55.78095],[39.42254,55.78096],[39.42637,55.77306],[39.44994,55.77702],[39.45377,55.77361],[39.44518,55.76894],[39.46908,55.76895],[39.47069,55.74721],[39.4863,55.74488],[39.52132,55.74578],[39.52422,55.78727],[39.5934,55.78921],[39.59374,55.79873],[39.62499,55.7987],[39.62597,55.80553],[39.64479,55.80533],[39.64571,55.79617],[39.66038,55.79597],[39.66097,55.78627],[39.7021,55.78746],[39.69459,55.8137],[39.71277,55.81331],[39.71378,55.82391],[39.73006,55.82478],[39.73335,55.84129],[39.7841,55.84011],[39.79234,55.83165],[39.85338,55.84083],[39.86162,55.83399],[39.88811,55.83389],[39.90914,55.80042],[39.89749,55.78375],[39.90058,55.77458],[39.88774,55.76582],[39.90087,55.74117],[39.93073,55.73388],[39.93629,55.71895],[39.95351,55.72194],[39.97313,55.71272],[39.99445,55.68801],[40.01569,55.68733],[40.03749,55.67233],[40.05516,55.65534],[40.05314,55.6379],[40.08686,55.60119],[40.07377,55.58103],[40.05477,55.57845],[40.04902,55.52669],[40.16587,55.5276],[40.17319,55.52277],[40.16659,55.51683],[40.17078,55.50768],[40.19713,55.49805],[40.19489,55.4605],[40.15568,55.46129],[40.13345,55.43842],[40.14549,55.43414],[40.14436,55.41923],[40.17516,55.40009],[40.20486,55.34701],[40.18108,55.33343],[40.20389,55.31745],[40.18247,55.31493],[40.15217,55.27467],[40.15455,55.26578],[40.08555,55.25556],[40.0303,55.23571],[39.99417,55.20044],[39.98943,55.21358],[39.95382,55.20761],[39.92021,55.21539],[39.8798,55.20412],[39.83504,55.20506],[39.81382,55.19771],[39.80626,55.18514],[39.78492,55.18578],[39.75492,55.14949],[39.73845,55.14707],[39.70492,55.11715],[39.76604,55.1203],[39.80823,55.13879],[39.82375,55.13645],[39.83343,55.11901],[39.8621,55.11566],[39.85986,55.09698],[39.8035,55.00962],[39.776,55.03092],[39.75958,55.03362],[39.75864,55.01067],[39.68189,55.0098],[39.66046,55.01931],[39.66013,55.02829],[39.61681,55.02825],[39.61735,55.0001],[39.60287,54.988],[39.51776,54.98355],[39.52298,54.96972],[39.47503,54.94583],[39.46497,54.93139],[39.46834,54.91934],[39.48158,54.91716],[39.47405,54.90918],[39.48461,54.90171],[39.46325,54.90193],[39.46429,54.89177],[39.40174,54.86852],[39.39029,54.85442],[39.4167,54.84065],[39.38007,54.82147],[39.35663,54.78251],[39.33361,54.77255],[39.33403,54.75279],[39.35997,54.75511],[39.36927,54.74648],[39.33057,54.73007],[39.33567,54.71946],[39.3048,54.7246],[39.3007,54.73495],[39.27159,54.73566],[39.24675,54.73189],[39.23279,54.71842],[39.24055,54.69147],[39.23063,54.68527],[39.23901,54.67566],[39.25559,54.67817],[39.25774,54.65905],[39.24349,54.65402],[39.24674,54.64729],[39.23141,54.64648],[39.23636,54.63929],[39.18247,54.63784],[39.16307,54.66127],[39.14855,54.64312],[39.12747,54.64606],[39.13122,54.63448],[39.12411,54.63258],[39.11187,54.6332],[39.10415,54.64617],[39.08172,54.63456],[39.04401,54.63532],[39.0348,54.64499],[38.98357,54.62447],[38.99385,54.61602],[38.97125,54.60144],[38.95259,54.60995],[38.95041,54.62255],[38.9195,54.63041],[38.88305,54.6162],[38.84334,54.62237],[38.82699,54.60699],[38.83752,54.58762],[38.82314,54.57923],[38.83493,54.56939],[38.79739,54.55095],[38.80839,54.53801],[38.84606,54.54319],[38.85285,54.53399],[38.80911,54.52477],[38.80212,54.51485],[38.80493,54.49969],[38.78928,54.49438],[38.77973,54.47894],[38.79916,54.47067],[38.80437,54.45054],[38.80531,54.45746],[38.82583,54.46284],[38.82967,54.45619],[38.87328,54.45148],[38.88296,54.44104],[38.93119,54.44017],[38.94091,54.40836],[38.89191,54.40259],[38.87079,54.39255],[38.8775,54.3717],[38.85872,54.37082],[38.85593,54.38762],[38.83671,54.39367],[38.81934,54.37463],[38.77534,54.37456],[38.77794,54.36369],[38.71412,54.34878],[38.70398,54.31921],[38.71152,54.30118],[38.70451,54.28984],[38.7209,54.28669],[38.70556,54.27312],[38.71447,54.27169],[38.70097,54.25991],[38.65725,54.25567],[38.63927,54.26437],[38.63171,54.27999],[38.60808,54.27646],[38.57179,54.29007],[38.51356,54.29437],[38.52011,54.30409],[38.5081,54.3123],[38.52018,54.32167],[38.50799,54.32796],[38.5166,54.33473],[38.50455,54.34558],[38.51294,54.35592],[38.50907,54.36194],[38.52788,54.38164],[38.52796,54.39575],[38.4744,54.40283],[38.45537,54.41553],[38.47235,54.42322],[38.45118,54.44086],[38.43239,54.44314],[38.41258,54.4614],[38.38762,54.467],[38.39612,54.47211],[38.39468,54.50068],[38.40272,54.5057],[38.38299,54.51183],[38.37701,54.52648],[38.42108,54.53999],[38.42203,54.546],[38.45011,54.53752],[38.43627,54.55011],[38.45898,54.55026],[38.44642,54.57282],[38.46202,54.5692],[38.51532,54.59254],[38.5002,54.61164],[38.48454,54.61497],[38.4837,54.63069],[38.45858,54.65283],[38.39768,54.6478],[38.39361,54.63658],[38.34721,54.65693],[38.31993,54.64976],[38.317,54.66063],[38.29092,54.67663],[38.27402,54.67394],[38.26061,54.66145],[38.2424,54.67008],[38.2355,54.66567],[38.21558,54.67905],[38.2137,54.69468],[38.15881,54.69502],[38.15123,54.68558],[38.1379,54.68476],[38.11904,54.71492],[38.06958,54.70659],[38.04997,54.72103],[38.02713,54.7253],[38.0294,54.73527],[38.04353,54.73467],[38.0409,54.76359],[38.01255,54.77656],[38.01547,54.78214],[37.98308,54.77575],[37.95456,54.78092],[37.98228,54.79839],[37.98974,54.82515],[37.97365,54.83957],[37.93733,54.85021],[37.74797,54.83293],[37.77923,54.81631],[37.77207,54.81191],[37.77751,54.80723],[37.76523,54.80409],[37.77082,54.78604],[37.78014,54.7855],[37.77718,54.7713],[37.76226,54.76915],[37.75729,54.75415],[37.7666,54.75244],[37.72562,54.72486],[37.68264,54.71757],[37.62718,54.74151],[37.56911,54.74153],[37.56496,54.73263],[37.54879,54.73782],[37.55629,54.75984],[37.545,54.78074],[37.51672,54.78114],[37.51356,54.78904],[37.49736,54.79279],[37.50334,54.80755],[37.44629,54.8423],[37.38399,54.84439],[37.37711,54.83859],[37.37126,54.85196],[37.35819,54.84922],[37.35539,54.83589],[37.33316,54.84621],[37.32553,54.8382],[37.31091,54.84036],[37.30174,54.85034],[37.29751,54.82986],[37.29066,54.82816],[37.26037,54.83482],[37.27484,54.84708],[37.25988,54.85108],[37.19997,54.84966],[37.19582,54.85755],[37.16405,54.86765],[37.17467,54.8787],[37.16905,54.89555],[37.19533,54.92382],[37.16171,54.95284],[37.17198,54.95753],[37.15979,54.95876],[37.16489,54.96594],[37.17257,54.96131],[37.1722,54.96813],[37.14836,54.981],[37.15551,54.98479],[37.13484,54.99138],[37.14977,54.99825],[37.11796,55.02546],[37.09381,55.03238],[37.0968,55.04586],[37.08198,55.05767],[37.11948,55.063],[37.11411,55.06765],[37.12094,55.07396],[37.11149,55.07896],[37.11662,55.09892],[37.09973,55.09671],[37.09556,55.10603],[37.07514,55.11207],[37.05353,55.1102],[37.05575,55.14351],[37.03896,55.14261],[37.01481,55.1602],[37.01924,55.18258],[36.98251,55.18054],[36.96423,55.21215],[36.94733,55.21836],[36.94659,55.24162],[36.88706,55.22768],[36.85804,55.22954],[36.87123,55.21506],[36.81451,55.19439],[36.80386,55.19728],[36.80395,55.21004],[36.81341,55.21432],[36.79372,55.2282],[36.79295,55.25209],[36.76633,55.2676],[36.73356,55.25814],[36.64494,55.27771],[36.64277,55.26688],[36.62342,55.26334],[36.599,55.28239],[36.61177,55.29574],[36.60696,55.31057],[36.6268,55.31128],[36.60348,55.33097],[36.61569,55.34817],[36.59969,55.34967],[36.57413,55.32907],[36.53552,55.32091],[36.53756,55.30655],[36.51681,55.29424],[36.5076,55.30292],[36.48621,55.30326],[36.43823,55.29066],[36.41837,55.30502],[36.39193,55.295],[36.38789,55.282],[36.36778,55.27839],[36.37911,55.27248],[36.37755,55.26316],[36.38699,55.2637],[36.38228,55.25252],[36.37047,55.24677],[36.36377,55.25414],[36.34398,55.25279],[36.33192,55.2191],[36.3012,55.198],[36.29989,55.19098],[36.31399,55.18668],[36.26304,55.17065],[36.25036,55.19074],[36.19352,55.1933],[36.16374,55.18909],[36.14034,55.17412],[36.12209,55.17909],[36.10646,55.20454],[36.07397,55.21789],[36.04761,55.216],[36.04309,55.22658],[36.02216,55.21662],[35.99823,55.21796],[35.95912,55.24119],[35.93096,55.23225],[35.91373,55.24932],[35.8409,55.2353],[35.81741,55.24506],[35.81469,55.2589],[35.76262,55.27806],[35.76549,55.28326],[35.74544,55.29624],[35.72333,55.28425],[35.70638,55.29164],[35.66447,55.27913],[35.61481,55.29374],[35.57766,55.29036],[35.56033,55.27565],[35.57667,55.26881],[35.57572,55.26144],[35.55934,55.24942],[35.53326,55.25841],[35.49961,55.25339],[35.50621,55.23867],[35.4487,55.2295],[35.40909,55.2372],[35.38584,55.23341],[35.36192,55.24434],[35.34926,55.26929],[35.3137,55.27248],[35.28999,55.29615],[35.30191,55.30461],[35.25769,55.33004],[35.27648,55.33135],[35.2801,55.34997],[35.28955,55.3525],[35.28527,55.38572],[35.3035,55.39814],[35.29805,55.41431],[35.32766,55.42925],[35.30458,55.43442],[35.31364,55.45383],[35.29145,55.46423],[35.29232,55.48074],[35.32107,55.48726],[35.31755,55.49604],[35.3248,55.50271],[35.31396,55.51814],[35.3478,55.52805],[35.29572,55.5551],[35.29688,55.57737],[35.33458,55.5821],[35.35016,55.57153],[35.36822,55.5755],[35.3669,55.58915],[35.39066,55.5933],[35.39031,55.60785],[35.37945,55.62975],[35.35054,55.6351],[35.35561,55.64013],[35.34601,55.65701],[35.319,55.66056],[35.33567,55.70045],[35.31368,55.71084],[35.30274,55.73596],[35.31142,55.74467],[35.3419,55.74041],[35.32936,55.76384],[35.34047,55.77212],[35.32922,55.79383],[35.28233,55.79932],[35.28703,55.81549],[35.28059,55.82554],[35.24758,55.84918],[35.2459,55.86283],[35.20638,55.89579],[35.2261,55.9102],[35.20569,55.90261],[35.1967,55.90815],[35.20497,55.91446],[35.1866,55.93184],[35.14411,55.95884],[35.19679,56.01143],[35.22242,56.014],[35.2396,56.03146],[35.23215,56.04276],[35.26809,56.04069],[35.28978,56.06407],[35.31546,56.0641],[35.32341,56.07794],[35.3176,56.08422],[35.33973,56.09233],[35.31622,56.10541],[35.286,56.10823],[35.29046,56.11471],[35.28462,56.12403],[35.3103,56.13108],[35.30994,56.13827],[35.29512,56.14416],[35.30665,56.15407],[35.33944,56.15932],[35.33621,56.16327],[35.36222,56.1791],[35.34996,56.18448],[35.36602,56.19725],[35.3212,56.20689],[35.31571,56.22779],[35.39262,56.23484],[35.41085,56.24795],[35.43997,56.2386],[35.46472,56.24107],[35.50098,56.25819],[35.47708,56.27507],[35.47256,56.28548],[35.48968,56.28944],[35.46737,56.30847],[35.49806,56.31583],[35.46574,56.33091],[35.47802,56.33648],[35.46961,56.33756],[35.48028,56.34564],[35.47768,56.35821],[35.49838,56.36234],[35.47057,56.36054],[35.48512,56.37329],[35.50583,56.36808],[35.50809,56.38065],[35.52136,56.3846],[35.51392,56.38963],[35.5204,56.39556],[35.49871,56.39987],[35.48188,56.38353],[35.46246,56.37814],[35.44595,56.38495],[35.41617,56.38278],[35.42964,56.42113],[35.43722,56.42053],[35.44015,56.43085],[35.45639,56.43042],[35.42772,56.44258],[35.43191,56.45893],[35.47212,56.45481],[35.4836,56.44562],[35.47408,56.43919],[35.49061,56.43219],[35.52366,56.43147],[35.52886,56.44188],[35.55676,56.45282],[35.55514,56.45804],[35.60157,56.47812],[35.62006,56.47738],[35.62555,56.46894],[35.61935,56.45744],[35.65231,56.46118],[35.66406,56.44789],[35.68609,56.44588],[35.68083,56.42901],[35.69897,56.42843],[35.71636,56.41064],[35.72966,56.41329],[35.73535,56.38977],[35.76998,56.38988],[35.78041,56.39955],[35.79074,56.3963],[35.80927,56.40541],[35.83993,56.39366],[35.85937,56.39504],[35.83536,56.3881],[35.84338,56.3809],[35.86351,56.38713],[35.86821,56.37203],[35.90549,56.37802],[35.95296,56.37049],[35.95823,56.37819],[36.01431,56.37802],[36.03582,56.36518],[36.05126,56.37295],[36.07404,56.36172],[36.06121,56.35144],[36.06202,56.33798],[36.08822,56.33591],[36.0994,56.37904],[36.10805,56.38787],[36.12393,56.38576],[36.1437,56.41796],[36.23708,56.40509],[36.2409,56.41426],[36.27231,56.41666],[36.30846,56.44131],[36.37711,56.44968],[36.40061,56.46752],[36.43741,56.47826],[36.539,56.47279],[36.54094,56.49648],[36.59088,56.49977],[36.61445,56.5154],[36.65179,56.5163],[36.64619,56.50564],[36.68168,56.49842],[36.65172,56.52327],[36.79991,56.56824],[36.813,56.57845],[36.80305,56.5959],[36.98027,56.56296],[36.96921,56.55409],[36.97264,56.54258],[37.06748,56.5262],[37.07494,56.53201],[37.07144,56.54591],[37.0977,56.54006],[37.14703,56.5863],[37.14439,56.59494],[37.12615,56.60195],[37.13532,56.61033],[37.12769,56.61321],[37.13386,56.62054],[37.11503,56.64046],[37.15449,56.64933],[37.14898,56.65478],[37.15912,56.65211],[37.15863,56.66221],[37.13005,56.66924],[37.15891,56.6817],[37.1543,56.69066],[37.1743,56.69646],[37.13746,56.71145],[37.07857,56.75497],[37.10646,56.75931],[37.10184,56.76775],[37.14679,56.77512],[37.2057,56.77008],[37.21542,56.78333],[37.24331,56.7866],[37.23843,56.77248],[37.22517,56.76749],[37.23857,56.74827],[37.24909,56.74557],[37.27181,56.75882],[37.28065,56.77525],[37.34383,56.76331],[37.34899,56.77984],[37.43669,56.79532],[37.45882,56.779],[37.4783,56.77659],[37.50504,56.80112],[37.51258,56.82087],[37.55027,56.8399],[37.54111,56.85337],[37.54424,56.86432],[37.56552,56.85992],[37.57122,56.86668],[37.57354,56.87609],[37.53852,56.88192],[37.52752,56.8923],[37.53363,56.90922],[37.55004,56.91137],[37.55005,56.91873],[37.57861,56.91441],[37.5999,56.92951],[37.64403,56.93426],[37.64867,56.94613],[37.67723,56.94052],[37.69935,56.96132],[37.72614,56.95757],[37.73337,56.94268]]]};

    var map = L.map('map').setView([55.754, 37.614], 8);
    
    var withBoundary = function(providerName) {
        return L.TileLayer.BoundaryCanvas.createFromLayer(
            L.tileLayer.provider(providerName),
            {boundary: geom, trackAttribution: true}
        )
    }
    
    L.control.layers({
        'OpenStreetMap.HOT': withBoundary('OpenStreetMap.HOT').addTo(map),
        'Stamen.Watercolor': withBoundary('Stamen.Watercolor'),
        'Esri.WorldStreetMap': withBoundary('Esri.WorldStreetMap'),
        'MapQuestOpen.Aerial': withBoundary('MapQuestOpen.Aerial')
    }, null, {collapsed: false}).addTo(map);
    
    </script>
</body>
</html>